<template>
  <div class="login-panel">
    <h1>数据一体化采集管理平台</h1>
    <el-tabs type="border-card" stretch v-model="currentTab">
      <el-tab-pane name="account">
        <template #label>
          <span>
            <el-icon><Avatar /></el-icon>账户登录
          </span>
        </template>
        <LoginAccount ref="loginAccountRef"></LoginAccount>
      </el-tab-pane>
      <el-tab-pane name="phone">
        <template #label>
          <span>
            <el-icon><Iphone /></el-icon>手机登录
          </span>
        </template>
        <LoginPhone ref="loginPhoneRef"></LoginPhone>
      </el-tab-pane>
    </el-tabs>
    <div class="account-control">
      <el-checkbox v-model="isKeepPassword">记住密码</el-checkbox>
      <el-link>忘记密码</el-link>
    </div>
    <el-button class="login-btn" type="primary" @click="handleLoginClick">立即登录</el-button>
  </div>
</template>

<script lang="ts">
import { defineComponent, ref } from 'vue'
import LoginAccount from './login-account.vue'
import LoginPhone from './login-phone.vue'
export default defineComponent({
  components: {
    LoginAccount,
    LoginPhone
  },
  setup() {
    const loginAccountRef = ref<InstanceType<typeof LoginAccount>>()
    const loginPhoneRef = ref<InstanceType<typeof LoginPhone>>()
    const currentTab = ref<string>('account')
    const isKeepPassword = ref(true)
    const handleLoginClick = () => {
      console.log(currentTab.value + '登录')
      if (currentTab.value === 'account') {
        loginAccountRef.value?.loginAction(isKeepPassword.value)
      } else {
        loginPhoneRef.value?.loginAction()
      }
    }
    return { isKeepPassword, handleLoginClick, loginAccountRef, loginPhoneRef, currentTab }
  }
})
</script>

<style scoped lang="less">
.login-panel {
  width: 360px;
  // margin-left: 400px;
  margin-bottom: 160px;
  .account-control {
    margin-top: 10px;
    display: flex;
    justify-content: space-between;
  }
  .login-btn {
    width: 100%;
    margin-top: 10px;
  }
}
</style>
